package com.example.logintest.controller;

import com.alibaba.fastjson.JSON;
import com.example.logintest.common.CodeMsg;
import com.example.logintest.common.Result;
import com.example.logintest.pojo.User;
import com.example.logintest.service.IImagesService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @Author: Lemon
 * @Description: TODO
 * @Date: 2024/8/29 18:00
 */
@Controller
@RequestMapping("/images")
public class ImagesController {

    @Resource
    private IImagesService imagesService;


    @GetMapping("/queryImagesUrl")
    @ResponseBody
    public Object queryImagesUrl() {
        int code = 0;
        Object msg = "成功";
        Map<String, Object> resultMap = new HashMap();
        try{
            List<Map<String, Object>> resultList = new ArrayList<>();
            resultList = imagesService.queryImagesUrl();
            if (resultList.size()==0){
                code = -1;
                msg = CodeMsg.NOT_FIND_DATA;
                resultMap.put("code",code);
                resultMap.put("msg",msg);
                return resultMap;
            }
            resultMap.put("code",code);
            resultMap.put("msg",msg);
            resultMap.put("data",resultList);
        }catch (Exception e){
            code = -1;
            msg = e.getMessage();
            resultMap.put("code",code);
            resultMap.put("msg",msg);
        }
        return resultMap;
    }

}
